# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=netwatch
pkgver=1.3.1_2
pkgrel=4
pkgdesc="monitor network connections"
arch=(loong64 x86_64)
url="http://www.slctech.org/~mackay/NETWATCH/netwatch.html"
license=('GPL')
options=(zipman)
depends=(ncurses)
source=(https://p5n.pp.ru/~sergej/dl/2023/netwatch-${pkgver/_/-}.tar.xz
        format-security.patch)
sha256sums=('d8c14e2f942b5e8e864bdc1e13f3ba307f6455b332b2a907a5caeec4857062e6'
            'cc7356f59127c16ed43f402cc588c59e8b017dceaacd5a5d9a10080b7b8eb59c')

prepare() {
  cd "$srcdir/$pkgname-${pkgver/_/-}"
  sed -i 's|${CC-cc} |${CC-cc} -O2 |g' configure
  patch -p1 -i ../format-security.patch # Fix format-security warnings
}

build() {
  cd "$srcdir/$pkgname-${pkgver/_/-}"
  export CFLAGS+=" -fcommon" # Fix build with GCC 10m
  ./configure --prefix=/usr
  make
}

package() {
  cd "$srcdir/$pkgname-${pkgver/_/-}"
  install -D -m0755 netwatch "$pkgdir"/usr/bin/netwatch
  install -D -m0755 netresolv "$pkgdir"/usr/bin/netresolv
  install -D -m0644 netwatch.1 "$pkgdir"/usr/share/man/man1/netwatch.1
}
